package com.annotation.hw.hw1;

import java.lang.reflect.Field;

/**
 * @author bin
 * @date 2025 - 03 -28
 **/
public class MainTest {
    public static void main(String[] args) throws Exception {
//        Student stu1 = new Student();
//        stu1.setAge(20);
//        Student stu2 = new Student();
//        stu2.setAge(17);

        Student stu1 = new Student("徐文斌",19);
        Student stu2 = new Student("徐文斌",17);
    }

    public static int check(Class<?> clazz,int ageValue) throws Exception {
        Field age = clazz.getDeclaredField("age");

        boolean isEx = age.isAnnotationPresent(myAnnotaion.class);

        if(isEx){
//            myAnnotaion ageValue1 = age.getAnnotation(myAnnotaion.class);
            if(ageValue > 18){
                System.out.println("年龄大于18");
                return ageValue;
            }else{
                throw new Exception("年龄小于18");
            }
        }
        return 0;
    }
}
